<template>
  <div>
    <ul>
      <li>
        <a href="JavaScript:;" @click="$router.push('/contacts/allcontacts')"
          >All contacts</a
        >
      </li>
      <li>
        <a href="JavaScript:;" @click="$router.push('/contacts/alice')"
          >Alice</a
        >
      </li>
      <li>
        <a href="JavaScript:;" @click="$router.push('/contacts/bob')">Bob</a>
      </li>
    </ul>
    <button @click="random">随机显示</button>
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: ['allcontacts', 'alice', 'bob'],
    }
  },
  methods: {
    random() {
      const R = Math.floor(Math.random() * this.arr.length)
      this.$router.push(`/contacts/${this.arr[R]}`)
    },
  },
}
</script>

<style></style>
